home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1761 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.6 KB  |  66 lines

  1. Path: noc.tor.hookup.net!the-fix.sos.on.ca
  2. From: <verneb@the-fix.sos.on.ca>
  3. Date: Tue,16 Jan 96 00:51:40 -0500
  4. Newsgroups: comp.lang.c
  5. Subject: Help with simple code
  6. Message-ID: <tcpnntpd.16.1.16.0.51.40.2781597121.342670@the-fix.sos.on.ca>
  7. References: <4dbak5$oij@ionews.io.org>
  8. Organization: the FIX - Kitchener, Ontario CANADA
  9. NNTP-Posting-Host: the-fix.sos.on.ca
  10. X-MajorTCP-Version: MajorTCP/IP [1.80-0]
  11.  
  12. To: INT:jgordon@io.org
  13.  
  14. Int:jgordon@io.org,
  15.  
  16. I >Can anyone tell me what's wrong with this piece of code? I lifted it
  17. I >straight from a textbook.
  18. I >
  19. I >Here's the code:
  20. I >
  21. I >/* Calculating compound interest */
  22. I >..h>
  23. I >..h>
  24. I >
  25. I >main()
  26. I >{
  27. I >    int year;
  28. I >    double amount, principal = 1000, rate = 0.5;
  29. I >
  30. I >    printf("%4s%21s\n", "Year", "Amount on deposit");
  31. I >
  32. I >    for (year = 1; year <= 10; year++) {
  33. I >        amount = principal * pow(1.0 + rate, year);
  34. I >        printf("%4d%21.2f\n", year, amount);
  35. I >    }
  36. I >
  37. I >    return 0;
  38. I >}
  39. I >______________________________________________________________
  40. I >
  41. I >and here's the error:
  42. I >
  43. I >In function `main':
  44. I >undefined reference to `pow'
  45. I >
  46. I >I don't understand. `pow' is a function, not a variable?
  47. I >Can anyone tell me what's wrong?
  48. I >
  49. I >
  50. I >
  51. I >     y = mon;
  52.     m = bill+POSTAGE;
  53.     r = pow(x,y);
  54.     z = bill*(float)r+POSTAGE;
  55.  
  56.                                                                     
  57. I don't know if this will help but this is how we used or set it up in 
  58. a billing program that I wrote a couple of years ago.  It might give 
  59. you an idea or two.
  60. Verne H. Bohlender
  61. Box 416, Chesley, Ontario.Ca. N0G 1L0
  62. verneb@The-Fix.sos.on.ca
  63. ___
  64. * UniQWK #2158*
  65.  
  66.